<template>
  <zm-view ref="view">
    <deco-entry-vip ref="deco" :data="decoData" page="vip" :default-vip-level="vipLevel" :read-only="readOnly"></deco-entry-vip>
  </zm-view>
</template>

<script>
import page from "@/mixins/page"
import { mapGetters } from "vuex"
import { mitt } from "@/utils/mitt"
export default {
  mixins: [page],
  data() {
    return {
      vipLevel: 0,
      readOnly: false
    }
  },
  computed: {
    ...mapGetters(["vipOneDeco", "vipTwoDeco"]),
    decoData() {
      const list = [this.vipOneDeco, this.vipTwoDeco]
      return list[this.vipLevel]
    }
  },
  onLoad(options) {
    this.readOnly = options.readOnly == "true" || options.readOnly
    this.vipLevel = options.vipLevel
  },
  created() {
    this.handleInit()
  },
  methods: {
    handleInit() {
      mitt.on("deco-vip-privilege.change", (index) => {
        this.vipLevel = index
      })
    }
  }
}
</script>

<style lang="scss" scoped></style>
